﻿using System.Collections;

namespace DelegateT1
{
    //? 一个代理类型
    public delegate void StringAssignmentEventHandler2();

    public class AnonymousInvokeList
    {
        //? 代理集合，内含一组具体方法
        private string[] message = new string[3];

        public AnonymousInvokeList()
        {
            StringAssignmentEventHandler2 handler2 = null;
            //? 直接用匿名方法 {}中就是方法的实现
            handler2 += delegate { message[0] = "Hello"; };
            handler2 += delegate { message[1] = ","; };
            handler2 += delegate { message[2] = "World!"; };
            handler2.Invoke();
        }

        public string this[int index]
        {
            get { return message[index]; }
        }
    }
}